<template>
    <view class="content">
        <view class="wrapper">
            <view class="top">
                <view class="title">{{data.title}}</view>
                <view class="time">{{data.date}}</view>
            </view>
            <view class="box">
                <u-parse :html="data.details"></u-parse>
                <view class="img-box">
                    <image class="img" mode="aspectFill" :src="el.image" v-for="(el, ind) in data.images" :key="ind"  @click="doPreview(data.images, ind)"></image>
                </view>
            </view>
        </view>
        
        <view class="f-tit">陪伴师</view>
        <view class="item" v-for="(item, index) in data.service_staff" :key="index">
            <image :src="item.image" class="avatar"></image>
            <view class="u-flex-1">
                <view class="item-r-t">
                    <view class="name">{{item.name}}</view>
                    <view class="real">已实名</view>
                    <u-icon name="star-fill" color="#fec427" size="28"></u-icon>
                    <view class="star-num">{{item.star}}</view>
                </view>
                <view class="great">擅长：{{item.be_good_at}}</view>
            </view>
            <view class="btn" @click="$gTo(`/mine/pages/service/service-details?id=${item.id}`)">查看详情</view>
        </view>
        
        <view style="text-align: center;padding: 30upx 0;color: #999;font-size: 24rpx;" v-if="!data.service_staff || data.service_staff.length == 0">暂无相关陪伴师</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                type: 0,
                id: '',
                data: {},
            };
        },
        onLoad(option) {
            if (option.id) {
                this.id = option.id
            }
            if (option.type) {
                this.type = option.type
            }
            this.getData()
        },
        methods: {
            //预览照片
            doPreview(item, index) {
                let arr = []
                item.forEach(cur => {
                    arr.push(cur.image)
                })
                uni.previewImage({
                    urls: arr,
                    current: index,
                    longPressActions: {
                        success: function(data) {
                        },
                        fail: function(err) {
                        }
                    }
                });
            },
            
            getData() {
            	this.$ajax('activity_detail', {
            		user_token: this.$getSync('userToken'),
                    id: this.id,//活动id
            	}).then(ret => {
            		if (ret.success == 1000) {
            			this.data = ret.detail
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    
    
    page{
        background-color: #f5f5f5;
    }
    .content{
        padding: 20rpx;
    }
    .wrapper{
        background-color: #fff;
        border-radius: 15rpx;
        padding: 35rpx 25rpx;
    }
    .top{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding-bottom: 35rpx;
        border-bottom: 2rpx solid #eee;
    }
    .title{
        font-size: 36rpx;
        font-weight: bold;
        padding-bottom: 10rpx;
    }
    .time{
        font-size: 24rpx;
        color: #666666;
    }
    .box{
        padding-top: 40rpx;
    }
    .img-box{
        padding-top: 30rpx;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
    }
    .img{
        width: 220rpx;
        height: 220rpx;
        margin-right: 15rpx;
        margin-bottom: 15rpx;
    }
    .img:nth-child(3n) {
        margin-right: 0;
    }
    
    .f-tit{
        font-size: 34rpx;
        font-weight: bold;
        padding: 30rpx 0 20rpx;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 30rpx 20rpx;
        background-color: #fff;
        border-radius: 20rpx;
        margin-bottom: 20rpx;
    }
    .avatar{
        width: 95rpx;
        height: 95rpx;
        border-radius: 50%;
        margin-right: 20rpx;
    }
    .item-r-t{
        display: flex;
        justify-content: flex-start;
        align-items: center;
    }
    .name{
        max-width: 250rpx;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 32rpx;
        font-weight: bold;
    }
    .real{
        padding: 7rpx 8rpx;
        background-color: #000;
        border-radius: 6rpx;
        font-size: 20rpx;
        color: #feeca8;
        line-height: 1;
        margin: 0 10rpx;
    }
    .star-num{
        font-size: 28rpx;
        font-weight: bold;
        padding-left: 6rpx;
    }
    .great{
        font-size: 24rpx;
        color: #949494;
        padding-top: 10rpx;
        width: 400rpx;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .btn{
        font-size: 25rpx;
        color: #fff;
        padding: 12rpx 16rpx;
        background-color: #f29700;
        border-radius: 10rpx;
    }

</style>
